/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86136
 * Date: 2024-07-16
 * Time: 10:46
 */
class MyArray<E> {
    public Object[] array = new Object[10];

    public void setArray(int pos,E val) {
        array[pos] = val;
    }
    public E getArray(int pos) {
        return (E)array[pos];
    }
}



sealed class Person permits Student,Teacher,Doctor {
    //sealed修饰Person 代表当前类是密封类 sealed修饰的类必须要有⼦类
}
non-sealed class Student extends Person{
    //使⽤ non-sealed 关键字修饰。表⽰不限制，任何类都可以继承。
}
final class Teacher extends Person {
    //类被 final 修饰了，被修饰的类就变成完全封闭的状态了，所有类都没办法继承。
}
sealed class Doctor extends Person permits manDoctor{
    //Doctor继承Person,由于Doctor被sealed修饰所以必须要有子类继承
}
non-sealed class manDoctor extends Doctor {
    //由于Doctor被sealed修饰所以必须要有子类继承Doctor
}
/*
class OrgCat {
    public var name;//error--不能使⽤var来声明字段
    public var eat(var str) {//error--不能使⽤var来声明⽅法参数,不能使⽤var来声明⽅法返回类型
    }
}
public static void main(String[] args) {
        var complexMap2 = 10;//ok
        System.out.println(complexMap2);
        var str = null;//error--var声明变量必须初始化，但是不能初始化为null
    }
 */


public class Test {
    public static void main(String[] args) {

        String data = "one";

        int result = switch (data) {
            case "one" : yield 1;
            case "two" : yield 2;
            default : yield 0;
        };
        System.out.println(result);
    }
    public static void main3(String[] args) {
        String data = "one";
        int result = switch (data) {
            case "one" -> 1;
            case "two" -> 2;
            default -> 0;
        };
        System.out.println(result);
    }
    public static void main2(String[] args) {
        String data = "one";
        int result = 0;
        switch (data) {
            case "one":
                result = 1;
                break;
            case "two":
                result = 2;
                break;
        }
        System.out.println(result);
    }
    public static void main1(String[] args) {
        MyArray<Integer> myArray = new MyArray<>();
        myArray.setArray(0,10);
        myArray.setArray(1,20);
        //myArray.setArray(2,2.3);
        System.out.println(myArray.getArray(0));
        System.out.println(myArray.getArray(1));
    }
}